home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / get_dr1r / tv.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-06-29  |  5.1 KB  |  118 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   0  'None
  4.    Caption         =   "Form1"
  5.    ClientHeight    =   3195
  6.    ClientLeft      =   150
  7.    ClientTop       =   435
  8.    ClientWidth     =   4680
  9.    Icon            =   "TV.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   213
  12.    ScaleMode       =   3  'Pixel
  13.    ScaleWidth      =   312
  14.    ShowInTaskbar   =   0   'False
  15.    StartUpPosition =   3  'Windows Default
  16.    Begin VB.Timer Timer1 
  17.       Interval        =   10
  18.       Left            =   960
  19.       Top             =   2640
  20.    End
  21.    Begin VB.PictureBox Picture1 
  22.       AutoSize        =   -1  'True
  23.       Height          =   645
  24.       Left            =   2040
  25.       Picture         =   "TV.frx":0442
  26.       ScaleHeight     =   585
  27.       ScaleWidth      =   2235
  28.       TabIndex        =   0
  29.       Top             =   1320
  30.       Width           =   2295
  31.    End
  32. Attribute VB_Name = "Form1"
  33. Attribute VB_GlobalNameSpace = False
  34. Attribute VB_Creatable = False
  35. Attribute VB_PredeclaredId = True
  36. Attribute VB_Exposed = False
  37. Private Sub Form_Load()
  38.    'add to system tray
  39.    With nidProgramData
  40.         .cbSize = Len(nidProgramData)
  41.         .hwnd = Form1.hwnd
  42.         .uId = vbNull
  43.         .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
  44.         .uCallbackMessage = WM_MOUSEMOVE
  45.         .hIcon = Form1.Icon
  46.         .szTip = "We're On TV" & vbNullChar
  47.     End With
  48.   Shell_NotifyIcon NIM_ADD, nidProgramData
  49.   oldfocus = GetForegroundWindow()             ' get currently active window
  50.   frmx = Screen.Width / Screen.TwipsPerPixelX - (Picture1.Width / 1.5)    ' calculate screen positions
  51.   frmy = 0
  52.   'set form1 to be top window
  53.   tmpval = SetWindowPos(Form1.hwnd, HWND_NOTOPMOST, frmx, frmy, Picture1.Width, Picture1.Height, SWP_SHOWME)
  54.   'set variables
  55.   angle_x = 0 'logo x angle
  56.   angle_y = 0 'logo y angle
  57.   speed = 5    'spin speed
  58.   i = 0               'general dogs body variable... ;)
  59.   screendc = CreateDC("DISPLAY", "", "", 0&) 'get screen device context
  60.      
  61.   LogoDC = NewDC(Form1.hDC, Picture1.Width, Picture1.Height) 'create work areas for logo
  62.   BackDC = NewDC(Form1.hDC, Picture1.Width, Picture1.Height)
  63.   StageDC = NewDC(Form1.hDC, Picture1.Width, Picture1.Height)
  64.   tmpval = SelectObject(LogoDC, Picture1) ' copy logo
  65.   tmpval = BitBlt(BackDC, 0, 0, Picture1.Width, Picture1.Height, screendc, frmx, frmy, SRCCOPY) ' set background of work area
  66.        
  67.   'for use later when setting window visible but not active
  68.   currWinP.Length = Len(currWinP)
  69.   currWinP.flags = 0&
  70.   currWinP.showCmd = SW_SHOWNOACTIVATE
  71.        
  72.   Form1.Hide   ' hide form1
  73.   winvis = False   'form1 hidden
  74. End Sub
  75. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  76.       If X = WM_RBUTTONUP Then  ' was the r-button clicked on system tray
  77.         Form1.PopupMenu Form2.mnu_shell 'Yep, display popup menu
  78.      End If
  79. End Sub
  80. Private Sub Timer1_Timer()
  81.     tmpval = GetCursorPos(mouse)   'get mouse position
  82.     curfocus = GetForegroundWindow()    ' get currently active window
  83.     If (mouse.X > frmx And mouse.Y < Picture1.Height) Or (curfocus <> oldfocus) Then      'is the mouse on the form or has the active window changed????
  84.         oldfocus = curfocus   ' update old active window
  85.         If winvis = True Then    ' if were displaying then ....
  86.             currWinP.showCmd = SW_HIDE         ' set window to hide
  87.             tmpval = SetWindowPlacement(Form1.hwnd, currWinP)    ' hide window
  88.             winvis = False    ' window hidden
  89.         End If
  90.     Else
  91.         If mouse.X < frmx Or mouse.Y > frmy + Picture1.Height Then  ' is mouse on form1?
  92.             If winvis = False Then ' is form1 hidden?
  93.                 tmpval = BitBlt(BackDC, 0, 0, Picture1.Width, Picture1.Height, screendc, frmx, frmy, SRCCOPY) 'as form1 is hidden grab screen
  94.                 currWinP.showCmd = SW_SHOWNOACTIVATE ' set form1 to show but not activate
  95.                 tmpval = SetWindowPlacement(Form1.hwnd, currWinP) 'send to form1
  96.                 tmpval = SetWindowPos(Form1.hwnd, HWND_TOPMOST, frmx, frmy, Picture1.Width, Picture1.Height, SWP_SHOWME) ' show form1
  97.                 winvis = True 'form1 visible
  98.             End If
  99.         End If
  100.         tmpval = BitBlt(StageDC, 0, 0, Picture1.Width, Picture1.Height, BackDC, 0, 0, SRCCOPY) 'copy background to stage area
  101.         
  102.         For i = Form1.Picture1.Width To 1 Step -1
  103.             tmpval = BitBlt(StageDC, Cos(degtorad(angle_x + i)) * (Picture1.Width / 3.2) + (Picture1.Width / 3.2), Sin(degtorad(angle_y + i)) * (5) + 2.5, 1, Picture1.Height, LogoDC, i, 0, SRCAND) ' put spinning logo onto stage area
  104.         Next i
  105.         tmpval = BitBlt(Form1.hDC, 0, 0, Picture1.Width, Picture1.Height, StageDC, 0, 0, SRCCOPY) ' copy stage to form1
  106.         
  107.         angle_x = angle_x + speed ' rotate logo x
  108.         angle_y = angle_y + speed ' rotate logo y
  109.         
  110.         If angle_x >= 360 Then  ' have we done a full rotation 360o??
  111.             angle_x = 0  ' Yep, reset angle
  112.         End If
  113.         If angle_y >= 360 Then
  114.             angle_y = 0
  115.         End If
  116.     End If
  117. End Sub
  118.